using UnityEngine;
using System.Collections;

/// \class  gkAbyssalGiantPlantTipWaterFlux
/// \brief  Plant tip physic
[AddComponentMenu("GK/AbyssalGiant/Plant/gkAbyssalGiantPlantTipWaterFlux")]
[RequireComponent(typeof(gkPhysicComponent))]
[RequireComponent(typeof(gkTransformPhysicController))]
public class gkAbyssalGiantPlantTipWaterFlux : MonoBehaviour 
{
	/// The flux max force
	public float MaxFluxForce = 5.0f;
	
	/// The flux Period
	public float FluxPeriod = 3.0f;
	
	/// The Physic component
	private gkPhysicComponent m_rPhysicComponent;
	
	/// \brief  Called just after the game begin to play
    void Start()
    {
        // Get the physic component
        m_rPhysicComponent = GetComponent<gkPhysicComponent>();
	}
	
	// \brief  Update is called once per frame
	void LateUpdate()
	{
		Vector3 f3WaterFluxForce = new Vector3();
		
		f3WaterFluxForce.x = Mathf.Cos(2.0f * Mathf.PI * Time.time / FluxPeriod) *  MaxFluxForce;
		
		m_rPhysicComponent.AddForce(f3WaterFluxForce);
	}
}